<script src="scripts/mathprocessor.js" type="text/javascript"></script>
<script type="text/javascript">
//<![CDATA[

var parser = new MathParser(), f = document.forms.math;

parser.add("userFunction", function(n, m){
    return n + m;
});

function computeValue(formula_id, value_id)
{
    var y=document.getElementById(formula_id).value;
    try{
        document.getElementById(value_id).value = parser.parse(y);
        //alert(document.getElementById(value_id).value);
    }catch(e){
        document.getElementById(value_id).value = "";
        // Ignore this unrecognized expression...
        //alert('Empty value');
    }
}
//]]>
</script>
<form action="/math" method="post" class="formula" onsubmit="computeValue('formula_id','value_id')" name="entry">
    <fieldset>
        <input type="text" name="formula" id="formula_id" size="100"/>
        <input type="hidden" name="value" id="value_id"/>
        <span class="submit"><input type="submit" value="Compute..."></span>
    </fieldset>
</form>